package com.ys.nms.module.business.dal.mysql.alerts;

import java.util.*;

import com.ys.nms.framework.common.pojo.PageResult;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.module.business.dal.dataobject.alerts.AlertsDO;
import org.apache.ibatis.annotations.Mapper;
import com.ys.nms.module.business.controller.admin.alerts.vo.*;

/**
 * 报警 Mapper
 *
 * @author zzy
 */
@Mapper
public interface AlertsMapper extends BaseMapperX<AlertsDO> {

    default PageResult<AlertsDO> selectPage(AlertsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AlertsDO>()
                .eqIfPresent(AlertsDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(AlertsDO::getRuleId, reqVO.getRuleId())
                .eqIfPresent(AlertsDO::getState, reqVO.getState())
                .eqIfPresent(AlertsDO::getAlerted, reqVO.getAlerted())
                .eqIfPresent(AlertsDO::getOpen, reqVO.getOpen())
                .eqIfPresent(AlertsDO::getNote, reqVO.getNote())
                .eqIfPresent(AlertsDO::getTimestamp, reqVO.getTimestamp())
                .eqIfPresent(AlertsDO::getInfo, reqVO.getInfo())
                .orderByDesc(AlertsDO::getId));
    }

}